class Solution {

public:

	int jump(vector<int>& nums) {

		int pos, max_pos, cur_end;

		cur_end = pos = max_pos = 0;


		int n = nums.size(), time = 0, index = 0;

		while (cur_end < n - 1)

		{

			pos = index + nums[index];


			if (pos > max_pos)

				max_pos = pos;


			if (index == cur_end)

			{

				cur_end = max_pos;

				time++;

			}

			index++;


		}

		return time;

	}

};

